package com.hongxun.budget.ui.dialog;

import android.view.View;
import android.widget.EditText;

import com.hongxun.budget.R;
import com.hongxun.budget.utils.KeyBoardUtils;
import com.hongxun.budget.utils.TestingUtils;
import com.hongxun.interfaces.ResponseListener;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Created by admin on 2018/7/25.
 */

public class InputDialog2 extends BaseCenterFragmentDialog {

    @BindView(R.id.content)
    EditText content;
    @BindView(R.id.supplier)
    EditText supplier;

    String title;
    ResponseListener listener;

    @Override
    protected int getLayoutId() {
        return R.layout.dialog_input2;
    }

    @Override
    protected void initViews() {
        KeyBoardUtils.openKeybord(content, getActivity());
    }

    public InputDialog2 setListener(ResponseListener listener) {
        this.listener = listener;
        return this;
    }

    @OnClick({R.id.cancel, R.id.confirm})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.cancel:
                dismiss();
                break;
            case R.id.confirm:
                String result = content.getText().toString();
                if (!TestingUtils.isEmpty(context, result, "您的输入数据")) return;
                String ghs = supplier.getText().toString();
                listener.response(result, ghs);
                KeyBoardUtils.closeKeybord(content, getActivity());
                dismiss();
                break;
        }
    }
}
